cmake_minimum_required(VERSION 3.19)
project(controller)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(general_interface REQUIRED)
find_package(control-algorithm REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)

add_executable(tri_pid src/tri_pid.cpp)
target_link_libraries(tri_pid control_algorithm)
ament_target_dependencies(tri_pid
  rclcpp
  tf2
  std_msgs
  geometry_msgs
  sensor_msgs
  general_interface)
install(TARGETS tri_pid DESTINATION lib/${PROJECT_NAME})

add_executable(tri_pid_lc src/tri_pid_lc.cpp)
target_link_libraries(tri_pid_lc control_algorithm)
ament_target_dependencies(tri_pid_lc
  rclcpp
  rclcpp_lifecycle
  tf2
  std_msgs
  geometry_msgs
  sensor_msgs
  general_interface)
install(TARGETS tri_pid_lc DESTINATION lib/${PROJECT_NAME})

add_executable(odom src/odom.cpp)
ament_target_dependencies(odom
  rclcpp
  tf2
  std_msgs
  sensor_msgs
  nav_msgs)
install(TARGETS odom DESTINATION lib/${PROJECT_NAME})

add_executable(follow_prediction src/follow_prediction.cpp)
ament_target_dependencies(follow_prediction
  rclcpp
  tf2
  std_msgs
  nav_msgs
  general_interface
  tf2_geometry_msgs
  visualization_msgs)
install(TARGETS follow_prediction DESTINATION lib/${PROJECT_NAME})

# Install files
install(
  DIRECTORY launch/
  DESTINATION share/${PROJECT_NAME}/launch
)
install(
  DIRECTORY config/
  DESTINATION share/${PROJECT_NAME}/config
)

ament_package()
